﻿using System;
using HupunSDK_API.Request;
using HupunSDK.Common.Extend;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace HupunSDK_API
{
    class Program
    {
        static void Main(string[] args)
        {
            //QueryTradeTest();
            //CommitTradeTest();
            ModifyRemarkTest();
            //JsonSerializeTest();
        }

        static void QueryTradeTest()
        {
            QueryTradesRequest request = new QueryTradesRequest()
            {
                Limit = 20,
                Page = 1,
                BillCode = "XD201025000017"
            };

            HupunApiClient client = new HupunApiClient(new HupunApiConfig()
            {
                Key = "3523496937",
                Secret = "b8ee03afc77437c8dbfaafb2a0544f17",
                ApiUrl = "http://121.36.93.156/api"
            });
            client.ShowParams(request);
        }

        static void CommitTradeTest()
        {
            CommitTradeRequest request = new CommitTradeRequest()
            {
                BillCode = "XD201025000017",
                TradeStatus = 0,
                CommitType = 0
            };

            HupunApiClient client = new HupunApiClient(new HupunApiConfig()
            {
                Key = "3523496937",
                Secret = "b8ee03afc77437c8dbfaafb2a0544f17",
                ApiUrl = "http://121.36.93.156/api"
            });
            client.ShowParams(request);
        }

        static void JsonSerializeTest()
        {
            Console.WriteLine(JsonConvert.SerializeObject(new { test = new List<TempClass> { new TempClass() { temp = "a" }, new TempClass() { temp = "b" } } }));
        }

        class TempClass
        {
            public string temp { get; set; }
        }

        static void ModifyRemarkTest()
        {
            ModifyRemarkRequest request = new ModifyRemarkRequest()
            {
                BillCode = "XD201025000017",
                Orders = new List<OrderDetailRemark>()
                {
                    new OrderDetailRemark() { OrderId = "12345", Remark = "OrderRemark" }
                },
                Remark = "测试修改备注"
            };

            HupunApiClient client = new HupunApiClient(new HupunApiConfig()
            {
                Key = "3523496937",
                Secret = "b8ee03afc77437c8dbfaafb2a0544f17",
                ApiUrl = "http://121.36.93.156/api"
            });

            var res = client.Execute(request);
            Console.WriteLine(res.Data);
        }
    }
}
